<template>
	<view>
		<view class="page">
			<view class="title">课程列表</view>
			<view style="display: flex; margin-top: 20rpx; margin-left: 10rpx; flex-direction: row; flex-wrap: wrap;">
				<view class="course_select" v-for="(item, index) in courseList" :key="index" @click="jumpToVideo(item)">
					<view style="display: flex; flex-direction: column;">
						<view class="course_logo">
							<image :src="item.imageUrl" mode=""></image>
						</view>
						<view style="display: flex; flex-direction: column;">
							<text style="font-size: 20rpx; color: #313450;">{{item.name}}</text>
							<text style="font-size: 18rpx; color: #898A8F;">点击查看详细</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import cloudbase from '@cloudbase/js-sdk';

	const db = cloudbase.database();
	export default {
		data() {
			return {
				courseList: [],
			}
		},
		onLoad() {
			// this.courseList = [];
			this.getGuideCourseList();
		},
		methods: {
			jumpToVideo: function(item) {
				if (getApp().globalData.userInfo.openId != '') {
					uni.navigateTo({
						url: '../video/video?item=' + JSON.stringify(item)
					})
				} else {
					uni.navigateTo({
						url: '../login/login'
					})
				}
			},
			// 获取校长课堂
			getGuideCourseList: function() {
				db.collection('course').where({
					type: '校长课堂'
				}).get().then(res => {
					console.log(res.data);
					for(let i = 0; i < res.data.length; i++){
						console.log(res.data[i].status);
						if(res.data[i].status == '已发布'){
							this.courseList.push(res.data[i]);
						}
					}
					// this.institutionGuideCourseList = res.data;
					console.log(this.courseList);
				})
			}
		}
	}
</script>

<style>
	.page {
		width: 750rpx;
		height: 1500rpx;

		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #F3F5F7;
	}


	.course {
		width: 330rpx;
		height: 300rpx;
		margin-top: 30rpx;
		margin-left: 25rpx;
		border-radius: 16rpx;
		background-color: #FFFFFF;
	}


	.single_course {}

	.title {
		color: #FD973F;
		font-size: 18px;
		margin-top: 35rpx;
		display: flex;
		justify-content: center;
	}

	.class_background_img {
		/* background-color: #aa55ff; */
		width: 330rpx;
		height: 200rpx;


		/* 		border-top-left-radius: 16rpx;
		border-top-right-radius: 16rpx; */


	}

	.class_play_bar {
		margin-top: -47rpx;
		width: 330rpx;
		height: 40rpx;
		background-color: #b3afae;
		border-bottom-left-radius: 16rpx;
		border-bottom-right-radius: 16rpx;

		/* 设置透明度 为0.5*/
		opacity: 0.5;
		/* 容器置顶 */
		position: absolute;
		z-index: 998;



	}

	.class_Video_view {}

	.class_caption_title {
		font-size: 10px;
		font-weight: 100;
		margin: 3rpx;
		/* justify-content: center; */

	}

	.class_bottom_title {
		display: flex;
		font-weight: 150;
		font-size: 8px;
	}

	.background_photo {
		width: 330rpx;
		height: 200rpx;
		/* z-index: 999; */
	}

	.class_play_icon {
		/* background-color:#ffffff; */
		width: 22rpx;
		height: 22rpx;
		margin-top: 10rpx;
		margin-left: 25rpx;
		position: absolute;
		z-index: 999;
	}

	.class_Video_view {
		font-size: 8px;
		color: #FFFFFF;
		margin-left: 50rpx;
		margin-bottom: 50rpx;
	}


	.course_select {
		/* width: 220rpx; */
		padding: 10rpx;
		margin-top: 10rpx;
		margin-left: 0rpx;
		margin-right: 15rpx;
		margin-bottom: 10rpx;
		background-color: #FFFFFF;
		border-radius: 5px;
		box-shadow: 0 3px 6px rgba(0, 0, 0, .09);
	}

	.course_logo image {
		width: 210rpx;
		height: 297rpx;
		padding: 0rpx;
		margin-top: 0rpx;
		margin-left: 0rpx;
		margin-right: auto;
		margin-bottom: 5rpx;
		border-radius: 3px;
	}
</style>
